/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package momo.impl;

import java.util.Collection;

import momo.MomoPackage;
import momo.Operator;
import momo.Simplex;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Simplex</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link momo.impl.SimplexImpl#getX <em>X</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getY <em>Y</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getAngle <em>Angle</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getTransparency <em>Transparency</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getStartFrame <em>Start Frame</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getEndFrame <em>End Frame</em>}</li>
 *   <li>{@link momo.impl.SimplexImpl#getOperator <em>Operator</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SimplexImpl extends EObjectImpl implements Simplex {
	/**
	 * The cached value of the '{@link #getX() <em>X</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getX()
	 * @generated
	 * @ordered
	 */
	protected EList<Double> x;

	/**
	 * The cached value of the '{@link #getY() <em>Y</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getY()
	 * @generated
	 * @ordered
	 */
	protected EList<Double> y;

	/**
	 * The cached value of the '{@link #getAngle() <em>Angle</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAngle()
	 * @generated
	 * @ordered
	 */
	protected EList<Double> angle;

	/**
	 * The cached value of the '{@link #getTransparency() <em>Transparency</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTransparency()
	 * @generated
	 * @ordered
	 */
	protected EList<Double> transparency;

	/**
	 * The default value of the '{@link #getStartFrame() <em>Start Frame</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartFrame()
	 * @generated
	 * @ordered
	 */
	protected static final int START_FRAME_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getStartFrame() <em>Start Frame</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartFrame()
	 * @generated
	 * @ordered
	 */
	protected int startFrame = START_FRAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getEndFrame() <em>End Frame</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEndFrame()
	 * @generated
	 * @ordered
	 */
	protected static final int END_FRAME_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getEndFrame() <em>End Frame</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEndFrame()
	 * @generated
	 * @ordered
	 */
	protected int endFrame = END_FRAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOperator() <em>Operator</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperator()
	 * @generated
	 * @ordered
	 */
	protected Operator operator;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SimplexImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MomoPackage.Literals.SIMPLEX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Double> getX() {
		if (x == null) {
			x = new EDataTypeUniqueEList<Double>(Double.class, this, MomoPackage.SIMPLEX__X);
		}
		return x;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Double> getY() {
		if (y == null) {
			y = new EDataTypeUniqueEList<Double>(Double.class, this, MomoPackage.SIMPLEX__Y);
		}
		return y;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Double> getAngle() {
		if (angle == null) {
			angle = new EDataTypeUniqueEList<Double>(Double.class, this, MomoPackage.SIMPLEX__ANGLE);
		}
		return angle;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Double> getTransparency() {
		if (transparency == null) {
			transparency = new EDataTypeUniqueEList<Double>(Double.class, this, MomoPackage.SIMPLEX__TRANSPARENCY);
		}
		return transparency;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getStartFrame() {
		return startFrame;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStartFrame(int newStartFrame) {
		int oldStartFrame = startFrame;
		startFrame = newStartFrame;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.SIMPLEX__START_FRAME, oldStartFrame, startFrame));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getEndFrame() {
		return endFrame;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEndFrame(int newEndFrame) {
		int oldEndFrame = endFrame;
		endFrame = newEndFrame;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.SIMPLEX__END_FRAME, oldEndFrame, endFrame));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Operator getOperator() {
		if (operator != null && operator.eIsProxy()) {
			InternalEObject oldOperator = (InternalEObject)operator;
			operator = (Operator)eResolveProxy(oldOperator);
			if (operator != oldOperator) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MomoPackage.SIMPLEX__OPERATOR, oldOperator, operator));
			}
		}
		return operator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Operator basicGetOperator() {
		return operator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOperator(Operator newOperator) {
		Operator oldOperator = operator;
		operator = newOperator;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.SIMPLEX__OPERATOR, oldOperator, operator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MomoPackage.SIMPLEX__X:
				return getX();
			case MomoPackage.SIMPLEX__Y:
				return getY();
			case MomoPackage.SIMPLEX__ANGLE:
				return getAngle();
			case MomoPackage.SIMPLEX__TRANSPARENCY:
				return getTransparency();
			case MomoPackage.SIMPLEX__START_FRAME:
				return getStartFrame();
			case MomoPackage.SIMPLEX__END_FRAME:
				return getEndFrame();
			case MomoPackage.SIMPLEX__OPERATOR:
				if (resolve) return getOperator();
				return basicGetOperator();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MomoPackage.SIMPLEX__X:
				getX().clear();
				getX().addAll((Collection<? extends Double>)newValue);
				return;
			case MomoPackage.SIMPLEX__Y:
				getY().clear();
				getY().addAll((Collection<? extends Double>)newValue);
				return;
			case MomoPackage.SIMPLEX__ANGLE:
				getAngle().clear();
				getAngle().addAll((Collection<? extends Double>)newValue);
				return;
			case MomoPackage.SIMPLEX__TRANSPARENCY:
				getTransparency().clear();
				getTransparency().addAll((Collection<? extends Double>)newValue);
				return;
			case MomoPackage.SIMPLEX__START_FRAME:
				setStartFrame((Integer)newValue);
				return;
			case MomoPackage.SIMPLEX__END_FRAME:
				setEndFrame((Integer)newValue);
				return;
			case MomoPackage.SIMPLEX__OPERATOR:
				setOperator((Operator)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MomoPackage.SIMPLEX__X:
				getX().clear();
				return;
			case MomoPackage.SIMPLEX__Y:
				getY().clear();
				return;
			case MomoPackage.SIMPLEX__ANGLE:
				getAngle().clear();
				return;
			case MomoPackage.SIMPLEX__TRANSPARENCY:
				getTransparency().clear();
				return;
			case MomoPackage.SIMPLEX__START_FRAME:
				setStartFrame(START_FRAME_EDEFAULT);
				return;
			case MomoPackage.SIMPLEX__END_FRAME:
				setEndFrame(END_FRAME_EDEFAULT);
				return;
			case MomoPackage.SIMPLEX__OPERATOR:
				setOperator((Operator)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MomoPackage.SIMPLEX__X:
				return x != null && !x.isEmpty();
			case MomoPackage.SIMPLEX__Y:
				return y != null && !y.isEmpty();
			case MomoPackage.SIMPLEX__ANGLE:
				return angle != null && !angle.isEmpty();
			case MomoPackage.SIMPLEX__TRANSPARENCY:
				return transparency != null && !transparency.isEmpty();
			case MomoPackage.SIMPLEX__START_FRAME:
				return startFrame != START_FRAME_EDEFAULT;
			case MomoPackage.SIMPLEX__END_FRAME:
				return endFrame != END_FRAME_EDEFAULT;
			case MomoPackage.SIMPLEX__OPERATOR:
				return operator != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (x: ");
		result.append(x);
		result.append(", y: ");
		result.append(y);
		result.append(", angle: ");
		result.append(angle);
		result.append(", transparency: ");
		result.append(transparency);
		result.append(", startFrame: ");
		result.append(startFrame);
		result.append(", endFrame: ");
		result.append(endFrame);
		result.append(')');
		return result.toString();
	}

} //SimplexImpl
